-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix) if conditions control flow #846
Conversation
This adds an IfScope to svelte2tsx which keeps track of the if scope including nested ifs. That scope is used to prepend the resulting condition check to all inner lambda functions that svelte2tsx needs to create for slot, each, await. This way, TypeScript's control flow can determine the type of checked variables and no longer loses that info due to the lambda functions. sveltejs#619
add SnapshotFragmentMap util
@jasonlyu123 could you review this? The logic is a little complicated and I changed code in quite a few places (although most of the new code is tests) and I want to make sure I'm not doing something stupid here or if the approach I took here is not good in your opinion. High level summary: The if-conditions are repeated and prepended to the lambda functions to reinstantiate control flow. I introduced comments around them to be able to filter those repeats out when returning things like diagnostics,rename etc. That comment could possibly used in other places, too, later on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall great. Didn't found many problems. Just some minor one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
This adds an IfScope to svelte2tsx which keeps track of the if scope including nested ifs. That scope is used to prepend the resulting condition check to all inner lambda functions that svelte2tsx needs to create for slot, each, await. This way, TypeScript's control flow can determine the type of checked variables and no longer loses that info due to the lambda functions.
#619
TODO:
handle shadowed variablesremove hidden checks from getDefinitions/findReferences/diagnosticsfix rename